package com.herench.bs.handler;

import com.herench.bs.agent.IPersonAgent;
import com.herench.bs.annotation.Handler;
import com.herench.bs.support.AbstractMessageHandler;
import com.herench.bs.support.RequestMessage;
import com.herench.bs.support.ResponseMessage;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import java.util.Map;

/**
 * cleverClinic
 * com.herench.bs.handler
 *
 * @author wangwenkai
 * @date 2017/12/27/13:17
 * 修改默认就诊人
 */
@Component
@Handler(code = "100237" ,name="修改默认就诊人")
public class ModifyDefaultPersonHandler extends AbstractMessageHandler {
    @Override
    protected ResponseMessage innerHandler(RequestMessage requestMessage) throws Exception {
        ResponseMessage responseMessage =null;
        String channelCode = requestMessage.getArgsPropertyStringValue("sysCode");
        String personId = requestMessage.getArgsPropertyStringValue("personId");
        Assert.notNull(personId,"personId 不能为空！");
        String user = requestMessage.getArgsPropertyStringValue("user");
        Assert.notNull(user,"user 不能为空！");
        IPersonAgent personAgent = getCleverClinicContext().getApplicationContext().getBean(IPersonAgent.class);
        Map<String,Object> res = personAgent.modifyDefaultPersonHandler(channelCode,personId,user);
        responseMessage = new ResponseMessage(requestMessage.getId());
        responseMessage.setData(res);
        getPropertiesFromInvokerResultMap(responseMessage,res);
        return responseMessage;
    }
}
